<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>jsonP方法</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }
    </style>
    <script>
        // function fn(obj) {
        //     console.log(obj);
        // }
    </script>
</head>

<body>
    <!-- 
    此方法利用 script 标签访问URL不会跨域的特性，将返回值解析为JS文本
        
    -->

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <!-- <script src="http://192.160.0.100:9000/jsonp?callback=fn"></script> -->
    <script type="text/javascript">
        $.ajax({
            url: "http://192.160.0.100:9000/jsonp",
            dataType: 'jsonp',  // 请求方式为jsonp
            jsonpCallback: "fn",    // 自定义回调函数名
            success(res){
                console.log(res);
            }
        })


    </script>
</body>

</html>